package com.start.manager.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.start.manager.domain.entity.RoleButton;
import com.start.manager.dao.RoleButtonDao;
import com.start.manager.service.IRoleButtonService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author Lijian
 * @since 2020-01-07
 */
@Service
public class RoleButtonServiceImpl extends ServiceImpl<RoleButtonDao, RoleButton> implements IRoleButtonService {

    @Override
    public Set<Integer> findAllByRoleId(Integer roleId) {
        QueryWrapper<RoleButton> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("role_id", roleId);
        List<RoleButton> roleButtonList = this.baseMapper.selectList(queryWrapper);
        Set<Integer> buttonIdSet  = roleButtonList.stream().map(RoleButton::getButtonId).collect(Collectors.toSet());
        return buttonIdSet;
    }

}
